package com.google.gwt.gwtpages.client.page;

import com.google.gwt.dom.client.Style.Cursor;
import com.google.gwt.gwtpages.client.page.parameters.PageParameters;
import com.google.gwt.user.client.ui.RootPanel;

public class DefaultPageLoadingHandler implements PageEventHandler {

	public void afterPageShow(GWTPage pageLoadResult,
			PageParameters parameters, PageRequestSession session) {
	}

	public void onPageShowSuccess(GWTPage pageLoadResult,
			PageParameters parameters, PageRequestSession session) {
		RootPanel.getBodyElement().getStyle().setCursor(Cursor.DEFAULT);
	}

	public void onPageShowFailure(GWTPage pageLoadResult,
			PageParameters parameters, PageRequestSession session) {
		RootPanel.getBodyElement().getStyle().setCursor(Cursor.DEFAULT);
	}

	public boolean onPageRequest(String pageToken, String historyToken,
			GWTPageAttributes metaData, PageRequestSession session) {
		RootPanel.getBodyElement().getStyle().setCursor(Cursor.WAIT);
		return true;
	}

	public boolean beforePageShow(GWTPage pageLoadResult,
			PageParameters parameters, PageRequestSession session) {
		return true;
	}

	public void onPageLoaded(GWTPage result) {
	}

	public void onPageNotFound(String historyToken) {
		RootPanel.getBodyElement().getStyle().setCursor(Cursor.DEFAULT);
	}

	public void onPageLoadFailure(String historyToken, Throwable cause) {
		RootPanel.getBodyElement().getStyle().setCursor(Cursor.DEFAULT);
	}
}